<% layout('/layouts/default.html', {title: '指标汇总修改', libs: ['layout', 'dataGrid','inputmask','ueditor','validate']}){ %>
<div class="main-content">
    <div class="box box-main">
    <form id="inputForm" class="form-horizontal">
    <#form:hidden path="examId" value="${dcSupExamVo.dcSupExamInfo.id}"/>
    <#form:hidden path="exameOrg" value="${dcSupExamVo.exameOrg}"/>
    <#form:hidden path="scoreStatus" value="${dcSupExamVo.dcSupExamScore.scoreStatus}"/>
        <div class="box-body">
        <div class="row">
            <div class="form-unit">${text('汇总信息')}
<!--            <button  type="button" class="btn btn-primary btn-sm" onclick="chooseUser()">催办</button>-->
                <button type="button" class="btn btn-primary btn-sm" onclick="exportSumScore()" style="float:right;">导出</button>
            </div>
        </div>
        <table id="sumScoreDataGrid"></table>
    </div>
    <div class="box-body">
        <% if(dcSupExamVo.dcSupExamScore.scoreStatus != '2'){ %>
        <a href="javascript:void(0)" id="addDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> 增加加分项</a>
        <a href="javascript:void(0)" id="removeDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> 增加倒扣分项</a>
        <a href="javascript:void(0)" id="GridAddRowBtn"  style="display: none"></i> 增加减分项</a>
        <% }else{ %>
        <a href="javascript:void(0)"  class="btn btn-primary btn-sm mt10 mb10 disabled"><i class="fa fa-plus"></i> 增加加分项</a>
        <a href="javascript:void(0)"  class="btn btn-primary btn-sm mt10 mb10 disabled"><i class="fa fa-plus"></i> 增加倒扣分项</a>
        <% } %>
        <table id="addOrRemoveGrid"></table>
    </div>


        <div class="box-body">
            <table style="width: 100%; height: 28px;padding: 0 2px;" class="ui-jqgrid-ftable" cellspacing="0" cellpadding="0" border="0">
                <tr class="" style="background: #e6e6e6;width: 100%">
                    <th style="text-align: center;float: right;margin-right: 22%">总得分&nbsp;<span id="myAllscore"></span>&nbsp;分</th>
                </tr>
            </table>
        </div>
        <div class="box-footer">
            <div class="row">
                <div class="col-sm-offset-4 col-sm-8">
                    <% if(dcSupExamVo.dcSupExamScore.scoreStatus == '9'){ %>
                    <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit" onclick="saveSumScore();"><i class="fa fa-check"></i> ${text('提 交')}</button>&nbsp;
                    <% } %>
                    <button type="button" class="btn btn-sm btn-default btnList" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
                    <% if(dcSupExamVo.dcSupExamScore.scoreStatus=='0'){ %>
                    <button class="btn btn-sm btn-danger" id="withdraw" onclick="withdrawSumScore();"> ${text('撤回')}</button>&nbsp;
                    <% } %>
                </div>
            </div>
        </div>
    </form>
    </div>
</div>
<% } %>
<script>
    let addRowInitData={}
    $('#sumScoreDataGrid').dataGrid({
        data: ${toJson(dcSupExamVo.dcSupScoreList)},
        datatype: "local", // 设置本地数据
        editGrid: $("#scoreStatus").val()=='9',
        sortableColumn: false, // 列表不允许排序
        showFooter: true, // 是否显示底部合计行
        emptyDataHint: true,
        editGridInitRowNum:0,
        showRownum: true,
        columnModel: [
            {header:'${text("主键")}',hidden: true, name:'id',width:150, align:"left", frozen:true},
            {header:'${text("任务id")}',hidden: true, name:'examId',width:150, align:"left", frozen:true},
            {header:'${text("年度")}', name:'examYear' ,hidden: true, width:80, align:"center"},
            {header:'${text("指标类型")}', name:'quotaGroup',hidden: true, width:80, align:"center"},
            {header:'${text("类别")}',sortable:false, name:'quotaType', index:'a.message_number', width:100, align:"center",formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')}, val, '${text("未知")}', true);
                }},
            {header:'${text("序号")}',sortable:false,hidden: true, name:'sortNum', index:'a.task_title', width:50, align:"center"},
            {header:'${text("目标内容")}',sortable:false, name:'quotaContent', index:'a.task_type_name', width:320, align:"left" },
            {header:'${text("被考核单位名称")}',hidden: true,sortable:false, name:'exameOrgName', index:'a.task_type_name', width:150, align:"left" },
            {header:'${text("被考核单位编码")}',hidden: true,sortable:false, name:'exameOrg', index:'a.task_type_name', width:150, align:"left" },
            {header:'${text("考核方式")}', name:'assessMethod', width:150, align:"left", formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_assessment')}, val, '', true);
                }},
            {header:'单位',sortable:false, name:'quotaUnit',width:100, align:"left"},
            {header:'权数',sortable:false, name:'quotaWeight',  width:140, align:"center",
                formatter: function(val, obj, row, act){
                    if (val==null||val==''){val=0;}
                    return parseFloat(val).toFixed(2);
                }
            },
            {header:'百分比得分', name:'percentage', width:150,edittype:'text',editable:true, align:"center",editoptions:{'class':'form-control required',
                    dataInit: function(element){
                        let rowid=$(element).attr("rowid")
                        let data=$('#sumScoreDataGrid').dataGrid('getRowData', rowid);
                        $(element).attr("inputvalidate","score")
                        $(element).attr("exameOrgName",data.exameOrgName)
                        $(element).addClass('inputmask').attr({'data-inputmask-alias': "money", 'data-inputmask': "'digits':'2'",'range':'[0,120]'}).inputmask()
                        $(element).on("input",function (e){
                            let inputVal= $(element).val();
                            if (parseFloat(inputVal)<100){
                                $("#"+rowid+"_scoreReason").addClass("remarkValidator")
                            }else {
                                $("#"+rowid+"_scoreReason").removeClass("remarkValidator")
                            }
                            let quotaScore= accMul(accDiv(parseFloat(inputVal),100),data.quotaWeight);
                            $("#sumScoreDataGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp(quotaScore,3));
                            refreshZpCount();
                        })
                        $(element).wrapAll("<div class='input-group'></div>")
                        $(element).after('<span class="input-group-addon">%</span>')
                    }
                },unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();},
                formatter: function(val, obj, row, act){
                    if (val==''||typeof val=="undefined"){val=0;}
                    return parseFloat(val).toFixed(2)+"%";
             }},
            {header: "分数",name: 'quotaScore',edittype:'text',width: 150,align: 'center', formatter: function(val, obj, row, act){
                        if (val==''||typeof val=="undefined"){val=0;}
                        return parseFloat(val).toFixed(3);
                    }
            },
            {header:'${text("排名")}', name:'ranking', width:100, align:"center"},
            {header:'备注', name:'scoreReason', width:200, align:"left",classes:'autoHH',
                editable:true, edittype:'text', editoptions:{'maxlength':'200','placeholder':'备注，限制200字以内','autocomplete':'off','class':'form-control remarkValidator',
                    dataInit:function (element){
                        let rowid=$(element).attr("rowid")
                        let data=$('#sumScoreDataGrid').dataGrid('getRowData', rowid);
                        if (data.quotaGroup=='1'){
                            $(element).removeClass("remarkValidator")
                        }
                        if (parseFloat(data.percentage)==100){
                            $(element).removeClass("remarkValidator")
                        }
                    }
                }, unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}
            }
        ],
        autoGridHeight: function(){
            return 290;
        },
        onSelectRow: function(id, isSelect, event){

        },
        ajaxSuccess: function(data){

        }
    });

    $('#addDataGridAddRowBtn').click(function (){
        addRowInitData={examYear:${dcSupExamVo.dcSupExamInfo.examYear},examId:$("examId").val(),quotaClass:"2",quotaType:"14"}
        //校验总权数是否超过三分
        $('#GridAddRowBtn').click()
    })
    $('#removeDataGridAddRowBtn').click(function (){
        addRowInitData={examYear:${dcSupExamVo.dcSupExamInfo.examYear},examId:$("examId").val(),quotaClass:"3",quotaType:"13"}
        $('#GridAddRowBtn').click()
    })

    $('#addOrRemoveGrid').dataGrid({
        data: ${toJson(dcSupExamVo.dcSupExamQuotaAddList)},
        editGridInitRowNum:0,
        datatype: "local", // 设置本地数据
        sortableColumn: false, // 列表不允许排序
        editGrid: $("#scoreStatus").val()=='9',		  // 是否是编辑表格
        showFooter: true, // 是否显示底部合计行
        editGridAddRowBtn: $('#GridAddRowBtn'),	// 子表增行按钮
        showRownum: true,
        editGridAddRowInitData: function (e){
            return addRowInitData;
        },	// 新增行的时候初始化的数据
        columnModel: [
            {header:'${text("主键")}',hidden: true, name:'id',width:150, align:"left"},
            {header:'${text("任务id")}',hidden: true, name:'examId',width:150, align:"left"},
            {header:'${text("指标类型")}',hidden: true, name:'quotaClass',width:150, align:"left"},
            {header:'${text("年度")}', name:'examYear' ,hidden: true, width:80, align:"center"},
            {header:'${text("类别")}',sortable:false, name:'quotaType', index:'a.message_number', width:40, align:"center",formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')}, val, '${text("未知")}', true);
             },
             unformat: function(val, obj, cell){
                    return obj.colModel.data[obj.rowId]}
             },
            {header:'${text("目标内容")}',sortable:false, name:'quotaContent', index:'a.task_type_name', width:160, align:"left",
                editable:true,edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control required',dataInit:function (element){
                        $(element).attr("inputvalidate","quotaContent");
                    }},
                unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}
            },
            {header:'${text("考核方式")}', name:'assessMethod',  width:60, align:"center",
                formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_assessment')}, val, '', true);
                },
                unformat: function(val, obj, cell){
                    return obj.colModel.data[obj.rowId];
                },
                editable:true, edittype:'select', editoptions:{'class':'form-control',
                    items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
                        ${@DictUtils.getDictListJson('dc_exam_assessment')}),
                    itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
                        $(element).select2().on("change",function(){$(this).resetValid()});
                    }
                }
            },
            {header:'单位',sortable:false, name:'quotaUnit',width:45, align:"left",
                editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}, unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}
                },
            {header:'权数',sortable:false, name:'quotaWeight',width:270, align:"left",edittype:'text',
                editable:true,width: 70,align: 'center',editoptions:{ 'class':'form-control required gt0',
                    dataInit: function(element){
                        $(element).addClass('inputmask').attr({'data-inputmask-alias': "money", 'data-inputmask': "'digits':'2'",'min':'0.1'}).inputmask();
                        let rowid=$(element).attr("rowid")
                        let data=$('#addOrRemoveGrid').dataGrid('getRowData', rowid);
                        if (data.quotaClass=="2"){
                            $(element).attr("inputvalidate","quotaWeight");
                        }
                        $(element).on("input",function (e){
                            let inputVal= $(element).val();
                            if (inputVal>0){
                                $("#"+rowid+"_"+"percentage").removeAttr("readonly");
                                let percentage = $('#'+rowid+'_'+"percentage").val();
                                let quotaScore= accMul(accDiv(parseFloat(inputVal),100),percentage);
                                if (data.quotaClass=="3"){
                                    $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp((accSub(inputVal,quotaScore)),3));
                                }else {
                                    $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp(quotaScore,3));
                                }
                                // $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp(quotaScore,3));
                            }else{
                                $("#"+rowid+"_"+"percentage").val("0.00")
                                $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",0.000);
                                $("#"+rowid+"_"+"percentage").attr("readonly","readonly")
                            }
                            refreshZpCount();
                        })
                    }
                },unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();},
                formatter: function(val, obj, row, act){
                    if (val==null||val==''){val=0;}
                    return parseFloat(val).toFixed(2);
                }
            },
            {header:'百分比得分', name:'percentage', width:60,edittype:'text',editable:true, align:"center",editoptions:{'class':'form-control required gt1',
                    dataInit: function(element){
                        let rowid=$(element).attr("rowid")
                        let data=$('#addOrRemoveGrid').dataGrid('getRowData', rowid);
                        $(element).attr("inputvalidate","score")
                        if (data.percentage==null||data.percentage<=0){
                            $(element).attr("readonly",true)
                        }
                        $(element).addClass('inputmask').attr({'data-inputmask-alias': "money", 'data-inputmask': "'digits':'2'",'range':'[0,100]'}).inputmask()
                        $(element).on("input",function (e){
                            let inputVal= $(element).val();
                            let quotaWeight = $('#'+rowid+'_'+"quotaWeight").val();
                            let quotaScore= accMul(accDiv(parseFloat(inputVal),100),quotaWeight);
                            if (data.quotaClass=="3"){
                                $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp((accSub(quotaWeight,quotaScore)),3));
                            }else {
                                console.log(quotaScore)
                                $("#addOrRemoveGrid").jqGrid("setCell",rowid,"quotaScore",roundHalfUp(quotaScore,3));
                            }
                            refreshZpCount();
                            if (parseFloat(inputVal)<100){
                                $("#"+rowid+"_scoreReason").addClass("remarkValidator")
                            }else {
                                $("#"+rowid+"_scoreReason").removeClass("remarkValidator")
                            }
                        })
                        $(element).wrapAll("<div class='input-group'></div>")
                        $(element).after('<span class="input-group-addon">%</span>')
                    }
                },unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();},
                formatter: function(val, obj, row, act){
                    if (val==''||typeof val=="undefined"){val=0;}
                    return val.toFixed(2)+"%";
                }},
            {header: "分数",name: 'quotaScore',edittype:'text',width: 80,align: 'center',
                formatter: function(val, obj, row, act){
                    if (val==''||typeof val=="undefined"){val=0;}
                    return parseFloat(val).toFixed(3);
                }
            },
            {header:'备注', name:'scoreReason', width:90, align:"left",classes:'autoHH',
                editable:true, edittype:'text', editoptions:{'maxlength':'200','placeholder':'备注，限制200字以内','autocomplete':'off','class':'form-control remarkValidator',
                    dataInit:function (element){
                        let rowid=$(element).attr("rowid")
                        let data=$('#addOrRemoveGrid').dataGrid('getRowData', rowid);
                        if (parseFloat(data.percentage)==100){
                            $(element).removeClass("remarkValidator")
                        }
                    }
                }, unformat: function(val, obj, cell){return $('#'+obj.rowId+'_'+obj.colModel.name, cell).val();}
            },
            {header:'操作',name:'actions', width:80, sortable:false, fixed:true,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                    if (val == 'new'){
                        actions.push('<a href="#" onclick="js.confirm(\'你确认要删除这条数据吗？\', function(){$(\'#addOrRemoveGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a>&nbsp;');
                    }else{
                        // actions.push('<a href="#" onclick="$(\'#addOrRemoveGrid\').dataGrid(\'editRow\',\''+obj.rowId+'\',{keys:true,focusField:true});return false;"><i class="fa fa-pencil"></i></a>&nbsp;');
                    }
                    return actions.join('');
                }, editoptions: {defaultValue: 'new'},unformat: function(val, obj, cell){
                    return val;}}
        ],
        autoGridHeight: function(){return 'auto'}, // 设置自动高度
        editGridInitAllRowEdit: true,  // 是否初始化就编辑所有行（*** 重点 ***）
        onSelectRow: function(id, isSelect, event){

        },
        ajaxSuccess: function(data){
            refreshZpCount();
        }
    });


    function refreshZpCount(){
        let data = $('#sumScoreDataGrid').dataGrid('getRowData');
        let allQuotaWeight=0.0;
        let allQuotaScore=0.0;
        for (let i = 0; i < data.length; i++) {
            if (data[i].quotaScore == 'undefined' ||data[i].quotaScore==''){
                continue;
            }
            allQuotaWeight=accAdd(parseFloat(data[i].quotaWeight||0),allQuotaWeight);
            allQuotaScore=accAdd(parseFloat(data[i].quotaScore||0),allQuotaScore);
        }
        $('#sumScoreDataGrid').dataGrid("footerData", "set", {
            "quotaUnit" : "<center><span>汇总：</span></center>",
            "quotaWeight" : "总权数<span>&nbsp;"+parseFloat(allQuotaWeight).toFixed(2)+" &nbsp;</span>分",
            "quotaScore": "得分<span>&nbsp;"+parseFloat(allQuotaScore).toFixed(3)+" &nbsp;</span>分"
        }, false);
        let addRemovedata = $('#addOrRemoveGrid').dataGrid('getRowData');
        let addRemoveQuotaWeight=0.0;
        let addRemoveQuotaScore=0.0;
        for (let i = 0; i < addRemovedata.length; i++) {
            let quotaClass= addRemovedata[i].quotaClass;
            if (quotaClass=="2"){
                 addRemoveQuotaScore=accAdd(parseFloat(addRemovedata[i].quotaScore||0),parseFloat(addRemoveQuotaScore));
            }else if (quotaClass=="3"){
                addRemoveQuotaScore=accSub(parseFloat(addRemoveQuotaScore),parseFloat(addRemovedata[i].quotaScore||0));
            }
            addRemoveQuotaWeight=accAdd(parseFloat(addRemovedata[i].quotaWeight||0),addRemoveQuotaWeight);
        }

        $('#addOrRemoveGrid').dataGrid("footerData", "set", {
            "quotaUnit" : "<center><span>汇总：</span></center>",
            "quotaWeight" : "总权数<span>&nbsp;"+parseFloat(addRemoveQuotaWeight).toFixed(2)+" &nbsp;</span>分",
            "quotaScore": "得分<span>&nbsp;"+parseFloat(addRemoveQuotaScore).toFixed(3)+" &nbsp;</span>分"
        }, false)

        $("#myAllscore").text(accAdd(allQuotaScore,addRemoveQuotaScore).toFixed(3))
    }

    function saveSumScore(){
        $("#inputForm").validate({
            submitHandler: function(){
                let html=$('#inputForm').find('input');
                let remarks=$('.box-body').find('.remarkValidator');
                let quotaWeights=$('#addOrRemoveGrid').find('input[inputvalidate=quotaWeight]');
                let quotaContents=$('#addOrRemoveGrid').find('input[inputvalidate=quotaContent]');
                let hasValid=true;
                let allWeight=0.00;
                for (let i = 0; i <html.length; i++) {
                    let has= $("#inputForm").validate().element(html[i]);
                    if (has==false){hasValid=false}
                }
                if (!hasValid){return;}
                for (let i = 0; i <remarks.length; i++) {
                    let has= $("#inputForm").validate().element(remarks[i]);
                    if (has==false){hasValid=false}
                }
                if (!hasValid){return;}
                for (let i = 0; i <quotaWeights.length; i++) {
                    allWeight+=parseFloat($(quotaWeights[i]).val())
                }
                let quotaContentText=[];
                for (let i = 0; i < quotaContents.length; i++) {
                    quotaContentText.push($.trim($(quotaContents[i]).val()))
                }
                const newListLength=new Set(quotaContentText).size;
                const listLength=quotaContentText.length;
                if(listLength>newListLength){
                    js.alert('指标目标内容重复!',{icon: 2}, function(){

                    })
                    return;
                }
                if (hasValid){
                    //校验 总权数 总分不超过三分
                    if (allWeight>3.00){
                        js.alert('加分项总权数超过3分,禁止提交!',{icon: 2}, function(){
                        })
                    }else {
                        subSumScore();
                    }
                }
            }
        });

    }

    function subSumScore(){
        let allData =JSON.stringify($('#sumScoreDataGrid').dataGrid('getRowData'));
        let addOrRemoveData =JSON.stringify($('#addOrRemoveGrid').dataGrid('getRowData'));
        let subData = {
            "dcSupExamSumQuotaDtoListStr":allData,
            "dcSupExamQuotaAddListStr":addOrRemoveData,
            "exameOrg":$("#exameOrg").val(),
            "dcSupExamScore.examId":$("#examId").val()
        };
        js.ajaxSubmit({url:"${ctx}/score/dcSupExamSumScore/saveSumScore",data:subData,dataType: 'json',callback:function (data){
                if (data.result=="true"){
                    js.showMessage(data.message);
                    let url= js.addParam(js.removeParam("selectExamOrg",window.parent.location.href),"&selectExamOrg="+subData.exameOrg);
                    window.parent.location.replace(url);
                }else {
                    js.showMessage(data.message);
                }
            }})
    }

    function withdrawSumScore() {
        $.ajax({
            url: "${ctx}/score/dcSupExamSumScore/withdrawSumScore",
            type: "post",
            cache: false,
            async:false,
            data: {
                "examId":$("#examId").val(),
                "exameOrg":$("#exameOrg").val()
            },
            success: function(data){
                js.showMessage(data.message);
                let url= js.addParam(window.parent.location.href);
                window.parent.location.replace(url);
            }
        });
    }

    function accAdd(arg1,arg2){
        var r1,r2,m;
        try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
        try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
        m=Math.pow(10,Math.max(r1,r2))
        return (arg1*m+arg2*m)/m
    }

    function accSub(arg1,arg2){
        var r1,r2,m,n;
        try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
        try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
        m=Math.pow(10,Math.max(r1,r2));
        //last modify by deeka
        //动态控制精度长度
        n=(r1>=r2)?r1:r2;
        return ((arg1*m-arg2*m)/m).toFixed(n);
    }
    //四舍五入并且保留几位小数
    function roundHalfUp(num, n) {
        n = n ? parseInt(n) : 0;
        if(n <= 0) {
            return Math.round(num);
        }
        num = Math.round(num * Math.pow(10, n)) / Math.pow(10, n); //四舍五入
        num = Number(num).toFixed(n); //补足位数
        return num;}

    //乘
    function accMul(arg1, arg2) {
        var m = 0,
            s1 = arg1.toString(),
            s2 = arg2.toString();
        try {
            m += s1.split(".")[1].length;
        } catch (e) {}
        try {
            m += s2.split(".")[1].length;
        } catch (e) {}
        return (
            (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
            Math.pow(10, m)
        );
    }

    //除
    function accDiv(arg1, arg2) {
        var t1 = 0,
            t2 = 0,
            r1,
            r2;
        try {
            t1 = arg1.toString().split(".")[1].length;
        } catch (e) {}
        try {
            t2 = arg2.toString().split(".")[1].length;
        } catch (e) {}
        with (Math) {
            r1 = Number(arg1.toString().replace(".", ""));
            r2 = Number(arg2.toString().replace(".", ""));
            return (r1 / r2) * pow(10, t2 - t1);
        }
    }
</script>
<script>
    jQuery.validator.addMethod("jqgriddataCheck", function(v1,v2) {
        let rowid=$(v2).attr("rowid");
        let data=$('#addOrRemoveGrid').dataGrid('getRowData', rowid).quotaWeight;

        if (parseFloat(v1)==parseFloat(data)){
            return true;
        }
        if (parseFloat(v1)>parseFloat(data)){
            return false;
        }
        return true;
    },"当前行填写分数不正确");
    jQuery.validator.addMethod("gt0", function(v1,v2) {
        let val =  $(v2).val();
        if (val==null||val<=0){
            return false;
        }
        return true;
    },"所填数必须大于0");

    jQuery.validator.addMethod("gt1", function(v1,v2) {
        let val =  $(v2).val();
        if (val==null||val<0){
            return false;
        }
        return true;
    },"所填数必须大于等于0");
    jQuery.validator.addMethod("remarkValidator", function(v1,v2) {
        if (v1!=null && typeof v1 !="undefined" && v1.trim() !=''){
            return true
        }
        //1. 关键扣分不必填 2.分数不是
        return false;
    },"扣分原因");

    function chooseUser(){
        js.loading();
        js.layer.open({
            type: 2,
            title: ['催办'],
            area: ['800px', '400px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/home/supIndex/cuibanPage2?id=${dcSupExamVo.dcSupExamInfo.id}&org=${dcSupExamVo.exameOrg}",
            btn1: function (index, layero) {
            },
            success: function (data) {
                js.closeLoading(0, true);
            },
            end:function () {

            }
        });
    }

    function exportSumScore() {
        window.location.href ='${ctx}/score/dcSupExamSumScore/exportSumScore?examId=${dcSupExamVo.examId}&exameOrg=${dcSupExamVo.exameOrg}';
    }


</script>

<style>
    .ui-layout-content{
        padding: 0px !important;
    }
    #jqgh_addOrRemoveGrid_rn{
        display: none;
    }
    .autoHH{
        white-space: normal !important;
        height:auto;
        /*vertical-align:text-top;*/
        padding-top:2px;
        word-break:break-all;
    }
</style>
